using System;

namespace SimpleSocket.Args
{
    internal delegate void MessageProcessHandler(ArraySegment<byte> buffer, int readLength);
    internal sealed class MessageReceivedEventArgs
    {
        private readonly MessageProcessHandler _messageProcessHandler;

        public readonly ArraySegment<byte> Buffer;

        public MessageReceivedEventArgs(ArraySegment<byte> buffer, MessageProcessHandler messageProcessHandler)
        {
            Buffer = buffer;
            _messageProcessHandler = messageProcessHandler;
        }

        public void SetReadLength(int readLength)
        {
            _messageProcessHandler(Buffer, readLength);
        }
    }
}